﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WHControlLib;
using WHControlLib.CommonHelpers;
using WHControlLib.Controls;
using WHControlLib.Forms;
using WHUIdemo.Forms.PosDemoPageFrm;

namespace WHUIdemo.Forms
{
    public partial class POSUIDemo : Form
    {


     


        private bool _saleFrmBtClicked;

        public bool SaleFrmBtClicked
        {
            get { return _saleFrmBtClicked; }
            set
            {
                if (value)
                {
                    SaleButton.FirstFillcolor= Color.Red;
                }else SaleButton.FirstFillcolor= Color.Transparent;
                _saleFrmBtClicked = value; }
        }
        private bool _memberFrmBtClicked;

        public bool MemberFrmBtClicked
        {
            get { return _memberFrmBtClicked; }
            set
            {
                if (value)
                {
                    MemberButton.FirstFillcolor = Color.Red;

                }
                else MemberButton.FirstFillcolor = Color.Transparent;
                _memberFrmBtClicked = value; }
        }


        protected override void WndProc(ref Message msg)
        {
            if (msg.Msg == 513)
            {
                msg.Msg = 161;
                msg.LParam = IntPtr.Zero;
                msg.WParam = new IntPtr(2);
            }
            base.WndProc(ref msg);
        }


        private bool _minimized;
        public bool Minimized
        {
            get => this._minimized;
            set
            {
                if (this._minimized == value)
                    return;
                this._minimized = value;
            }
        }

        //protected override CreateParams CreateParams
        //{
        //    get
        //    {
        //    //    CreateParams createParams = base.CreateParams;
        //    //    //if (this.Minimized)
        //    //    if (this.WindowState == FormWindowState.Minimized)



        //    //    {
        //    //        createParams.Style |= 131072;
        //    //        return createParams;
        //    //    }
        //    //    createParams.ExStyle |= 33554432;
        //    //    return createParams;


        //    }
        //}


        //protected override CreateParams CreateParams
        //{
        //    get
        //    {
        //        CreateParams paras = base.CreateParams;
        //        paras.ExStyle |= 0x02000000;
        //        return paras;
        //    }
        //}


        public POSUIDemo()

        {
            //设置双缓冲开启禁止背景擦拭
            SetStyle(
                     ControlStyles.OptimizedDoubleBuffer
                     | ControlStyles.ResizeRedraw
                     | ControlStyles.Selectable
                     | ControlStyles.AllPaintingInWmPaint
                     | ControlStyles.UserPaint,

                     true);



            InitializeComponent();
        }


        private void whButton4_Click(object sender, EventArgs e)
        {
            //  this.Dispose();
         Close(); 
        }



SaleFrm salefrm = new SaleFrm();
MemberFrm memberFrm = new MemberFrm();
        SettIngFrm settingFrm = new SettIngFrm();

        PLeaseWaitFrm  waitMeFrm= new PLeaseWaitFrm ();

        private void POSUIDemo_Load(object sender, EventArgs e)
        {
            
            salefrm.TopLevel = false;

            salefrm.FormBorderStyle = FormBorderStyle.None;
            salefrm.Dock = System.Windows.Forms.DockStyle.Fill;
            
            memberFrm.TopLevel = false;

            memberFrm.FormBorderStyle = FormBorderStyle.None;
            memberFrm.Dock = System.Windows.Forms.DockStyle.Fill;


            settingFrm.TopLevel = false;

            settingFrm.FormBorderStyle = FormBorderStyle.None;
            settingFrm.Dock = System.Windows.Forms.DockStyle.Fill;

            waitMeFrm.TopLevel = false;

            waitMeFrm.FormBorderStyle = FormBorderStyle.None;
            waitMeFrm.Dock = System.Windows.Forms.DockStyle.Fill;





            FrmPages.Controls.Clear();
            FrmPages.Controls.Add(salefrm);
            salefrm.Show();
            SaleButton.IsSelectedMy= true;

            ddTimer.Interval= 5000;

            ddTimer.Tick += DdTimer_Tick;
            ddTimer.Start();
        }

            Timer ddTimer = new Timer();
        private void DdTimer_Tick(object sender, EventArgs e)
        {
            this.Invoke(new Action(() =>
            {

                WHNotify.ShowMsgNotify("你有新的订单", "新订单", false);
                whAngleMark1.MarkText = "订" + dd.ToString();

            }));


            dd++;
        }

        void CLickSelectClasS(object sender)
        {
            if (!((WHButton)sender is WHButton))
            {
                return;
            }
            WHButton wb = (WHButton)sender;
            ;
            wb.IsSelectedMy = true;
            foreach (var item in wb.Parent.Controls)
            {
                if (item is WHButton)
                {
                    WHButton w = (WHButton)item;
                    if (w != wb)
                    {
                        w.IsSelectedMy = false;
                    }

                }
            }

        }

        private void SaleButton_Click(object sender, EventArgs e)
        {
            CLickSelectClasS(sender);

            FrmPages.Controls.Clear();
            FrmPages.Controls.Add(salefrm);
            salefrm.Show();
        }

        private void MemberButton_Click(object sender, EventArgs e)
        {
            CLickSelectClasS(sender);

            FrmPages.Controls.Clear();
            FrmPages.Controls.Add(memberFrm);
            memberFrm.Show();
        }

        private void ReportButton_Click(object sender, EventArgs e)
        {
            CLickSelectClasS(sender);

            FrmPages.Controls.Clear();
            FrmPages.Controls.Add(waitMeFrm);
            waitMeFrm.Show();
          
        }

        private void SettingButton_Click(object sender, EventArgs e)
        {
            CLickSelectClasS(sender);
            FrmPages.Controls.Clear();
            FrmPages.Controls.Add(settingFrm);
            settingFrm.Show();


        }

        private void AISettingButton_Click(object sender, EventArgs e)
        {
            CLickSelectClasS(sender);
        }

        private void panel2_Paint(object sender, PaintEventArgs e)
        {

        }
        int dd = 0;
        private void timer1_Tick(object sender, EventArgs e)
        {
   
        }

        private void POSUIDemo_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (ddTimer!=null)
            {
                ddTimer.Stop();
                ddTimer.Dispose();
            }
        }

        private void whButton6_Click(object sender, EventArgs e)
        {
            ddTimer.Stop();
            //WHNotify.ShowMsgNotify("你有新的订单", "新订单", false);
            WHNotify.ShowWarningNotify("现在结束了接受订单模拟","操作提醒",true);

        }
    }



}
